/**
*@Author      ：anlzou
*@Date        ：23:16 2021/4/24
*@Github      ：https://github.com/anlzou
*@Description ：
*/
package com.anlzou.asmDemo;

import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;

import java.io.IOException;

public class Attacher {
    public static void main(String[] args) throws AttachNotSupportedException, IOException, AgentLoadException, AgentInitializationException {

        VirtualMachine vm = VirtualMachine.attach("34242"); // 目标 JVM pid
        vm.loadAgent("/path/to/agent.jar");
    }
}
